/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.switz.agendacita.persistence;

import com.switz.agendacita.dto.EmpresaPersonal;
import com.switz.agendacita.persistence.iface.EmpresaPersonalDao;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author jose angel
 */
@Repository
public class EmpresaPersonalDaoImpl extends JdbcDaoSupport implements EmpresaPersonalDao {

    @Autowired
    public EmpresaPersonalDaoImpl(DataSource dataSource) {

        setDataSource(dataSource);
    }

    @Override
    public void insertEmpresaPersonal(EmpresaPersonal empresaPersonal) {
        SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(
                getJdbcTemplate().getDataSource())
                .withTableName("empresapersonal");
        SqlParameterSource parameters = new BeanPropertySqlParameterSource(empresaPersonal);
        simpleJdbcInsert.execute(parameters);
    }
}
